/*
** fct_list.c for 42sh in /home/demesy_j/svn/quarante-deuxsh/trunk
** 
** Made by julien demesy
** Login   <demesy_j@epitech.net>
** 
** Started on  Mon Mar 12 11:17:11 2012 julien demesy
** Last update Mon Mar 12 11:17:12 2012 julien demesy
*/

#include	<stdlib.h>
#include	"list.h"

t_list		*create_list()
{
  t_list	*root;

  root = malloc(sizeof(*root));
  if (root != NULL)
    {
      root->prev = root;
      root->next = root;
    }
  return (root);
}

void		empty_list(t_list *list)
{
  t_list	*it;
  t_list	*next;

  it = list->next;
  while (it != list)
    {
      next = it->next;
      free(it);
      it = next;
    }
}

void		delete_list(t_list **list)
{
  empty_list(*list);
  free(*list);
  *list = NULL;
}
